﻿/*
自定义层提示
Create - 创建层
Show - 显示层
Hide - 隐藏层
*/
function Editor_DivClass() {
    this.__Select__ = [];
    this.__Container__ = null;

    this.Container = null;
};
Editor_DivClass.prototype.Create = function() {
    var m, n, doc = parent.document;
    if (!this.__Container__) {
        m = doc.createElement("div");
        n = doc.createElement("div");
        doc.body.appendChild(m);
        doc.body.appendChild(n);
    } else {
        m = this.__Container__;
        n = this.Container;
    }
    var mS = "position: absolute; display: none; background-color: #f2f2f2; left: 0; top: 0; z-index: 9997; filter: Alpha(Opacity=60); overflow: hidden; width: {0}px; height: {1}px;";
    var nS = "position: absolute; display: none; left: 0; top: 0; z-index: 9998; overflow: auto;; width: {0}px; height: {1}px;";
    var docE = doc.documentElement;
    var bodyW = docE.scrollWidth > docE.offsetWidth ? docE.scrollWidth : docE.clientWidth;
    var bodyH = docE.scrollHeight > docE.offsetHeight ? docE.scrollHeight : docE.clientHeight;

    m.style.cssText = Method.F(mS, bodyW, bodyH);
    n.style.cssText = Method.F(nS, bodyW, bodyH);

    this.__Container__ = m;
    this.Container = n;
};
Editor_DivClass.prototype.Show = function() {
    if (this.__Container__) {
        var dis = this.__Container__.style.display;
        if (dis && dis != "block") {
            this.__Container__.style.display = "block";
            this.Container.style.display = "block";
            // 隐藏所有 select
            var elements = parent.document.all.tags("SELECT");
            for (var i = 0; i < elements.length; i++) {
                this.__Select__.push(elements[i].style.visibility ? elements[i].style.visibility : "visible");
                elements[i].style.visibility = "hidden";
            }
        }
    }
};
Editor_DivClass.prototype.Hide = function() {
    if (this.__Container__) {
        var dis = this.__Container__.style.display;
        if (dis && dis != "none") {
            this.__Container__.style.display = "none";
            this.Container.style.display = "none";
            // 显示所有 select
            var elements = parent.document.all.tags("SELECT");
            for (var i = 0; i < elements.length; i++) {
                elements[i].style.visibility = this.__Select__.shift();
            }
        }
    }
};

/*
    鼠标拖动类
    Coor - 鼠标位置
    Down - 鼠标按下
    Up - 鼠标弹开
    Move - 鼠标移动
*/
function Editor_MouseClass() {
    this.__X__ = 0;
    this.__Y__ = 0;
    this.__Flag__ = false;
};
Editor_MouseClass.prototype.Coor = function() {
    var sT = document.documentElement.scrollTop;
    var sL = document.documentElement.scrollLeft;
    return { x: sL + event.clientX, y: sT + event.clientY };
};
Editor_MouseClass.prototype.Down = function() {
    if (event.srcElement == Method.G(Common.DivTitle)) {
        document.onselectstart = new Function("return false"); // 移动不可选
        var mouseAP = this.Coor();
        var divAP = Method.L(Method.G(Common.DivDialog));
        this.__X__ = mouseAP.x - divAP.AbsoluteLeft;
        this.__Y__ = mouseAP.y - divAP.AbsoluteTop;
        this.__Flag__ = true;
    }
};
Editor_MouseClass.prototype.Up = function() {
    document.onselectstart = {};
    this.__Flag__ = false;
};
Editor_MouseClass.prototype.Move = function() {
    if (event.button > 0) {
        if (this.__Flag__) {
            var mouseAP = this.Coor();
            var div = Method.G(Common.DivDialog);
            div.style.left = mouseAP.x - this.__X__;
            div.style.top = mouseAP.y - this.__Y__;
        }
    }
};